<template>
	<view class="">
		<index v-if="contentName === '首页'"></index>
		<worktable v-if="contentName === '服务台'"></worktable>
		<info v-if="contentName ==='物业信息'"></info>
		<mine v-if="contentName === '我的'"></mine>
		<u-tabbar :value="value7" :placeholder="false" :border="false" @change="name => value7 = name" :fixed="true"
			:safeAreaInsetBottom="true">
			<u-tabbar-item v-for="(item,index) in menuList" :text="item.pack_name"
				:icon="contentName === item.pack_name ? item.selected_icon_path : item.pack_icon " :key="index"
				@click="navChange(item)"></u-tabbar-item>
			<!-- <u-tabbar-item text="放映厅" icon="photo" ></u-tabbar-item>
			<u-tabbar-item text="直播" icon="play-right" ></u-tabbar-item>
			<u-tabbar-item text="我的" icon="account" ></u-tabbar-item> -->
		</u-tabbar>
	</view>

</template>

<script>
	import index from '@/pages/home/index/index';
	import info from '@/pages/home/info/info';
	import mine from '@/pages/home/mine/mine';
	import worktable from '@/pages/worktable/index';

	export default {
		components: {
			index,
			info,
			mine,
			worktable
		},
		data() {
			return {
				contentName: '首页',
				// isTenant: this.$util.isTenant(), //TENANT租户NOT_YET_TENANT不是租户Notloggedin未登录Admin管理员,
				loginInfo: this.$util.getStorage("loginInfo"),
				token: this.$util.getStorage("loginInfo").token,
				userId: this.$util.getStorage("loginInfo").id,
				value7: this.$store.state.tabbarIndex,
				currentIndex: 0,
				menuList: [],
				list: [{
						index: 0,
						pagePath: "pages/home/index/index",
						iconPath: "static/home.png",
						selectedIconPath: "static/home-a.png",
						text: "首页"
					},
					{
						index: 1,
						pagePath: "pages/worktable/index",
						iconPath: "static/tabbar/service.png",
						selectedIconPath: "static/tabbar/service-active.png",
						text: "服务台"
					},
					{
						index: 2,
						pagePath: "pages/home/info/info",
						iconPath: "static/house.png",
						selectedIconPath: "static/house-a.png",
						text: "物业信息"
					},
					{
						index: 3,
						pagePath: "pages/home/mine/mine",
						iconPath: "static/mine.png",
						selectedIconPath: "static/mine-a.png",
						text: "我的 "
					}
				]
			}
		},
		onShow() {
			console.log(22222)
		},
		//onLoad没效果
		onLoad() {
			this.getMenuList()
		},
		methods: {
			navChange(content) {
				// uni.navigateTo({
				// 	url: `/${content.pack_path}`
				// })
				this.$store.commit('changeTabbarIndex', this.value7)
				this.contentName = content.pack_name
				this.$store.commit('changeTabbarName', this.contentName)
				console.log('item222222222', content)
			},
			getMenuList() {
				let apiConnect = ''
				if (this.loginInfo.app) {
					apiConnect = 'app'
				} else {
					apiConnect = 'wx'
				}
				this.$util.post({
					url: `${apiConnect}/login/appRole`,
					data: {
						token: this.token || '',
						userID: this.userId || ''
					}
				}).then(res => {
					//更改未登录状态
					console.log('res2222222222222', res.package)
					this.menuList = res.package
				})
			},
		}
	}
</script>

<style lang="less" scoped>
	.list {
		position: fixed;
		bottom: 0;
		display: flex;
		justify-content: space-around;
		width: 100%;
		background-color: #fff;
		font-size: 20rpx;

		// padding-left: 40rpx;
		// padding-right: 40rpx;
		// padding-bottom: 40rpx;
		.list-item {
			display: flex;
			flex-direction: column;
			align-items: center;
			color: #000;

			.active-text {
				color: #3980fd;
				font-weight: 600;
			}
		}
	}
</style>